deps: Vec<(String, Arc<Fingerprint>)>,
local: LocalFingerprint,
memoized_hash: Mutex<Option<u64>>,
+ rustflags: Vec<String>,
}
#[derive(RustcEncodable, RustcDecodable, Hash)]
if self.profile != old.profile {
bail!("profile configuration has changed")
}
+ if self.rustflags != old.rustflags {
+ return Err(internal("RUSTFLAGS has changed"))
+ }
match (&self.local, &old.local) {
(&LocalFingerprint::Precalculated(ref a),
&LocalFingerprint::Precalculated(ref b)) => {
ref deps,
ref local,
memoized_hash: _,
+ ref rustflags,
} = *self;
- (rustc, features, target, profile, deps, local).hash(h)
+ (rustc, features, target, profile, deps, local, rustflags).hash(h)
}
}
(a, b.hash())
}).collect::<Vec<_>>().encode(e)
}));
+ try!(e.emit_struct_field("rustflags", 6, |e| self.rustflags.encode(e)));
Ok(())
})
}
features: String::new(),
deps: Vec::new(),
memoized_hash: Mutex::new(Some(hash)),
+ rustflags: Vec::new(),
}))
}).collect()
- }
+ },
+ rustflags: try!(d.read_struct_field("rustflags", 6, decode)),
})
})
}
deps: deps,
local: local,
memoized_hash: Mutex::new(None),
+ rustflags: cx.rustflags_args(unit),
});
cx.fingerprints.insert(*unit, fingerprint.clone());
Ok(fingerprint)
deps: Vec::new(),
local: local,
memoized_hash: Mutex::new(None),
+ rustflags: Vec::new(),
};
let compare = compare_old_fingerprint(&loc, &fingerprint);
log_compare(unit, &compare);
.arg("--target").arg(host),
execs().with_status(0));
});
+
+test!(rustflags_recompile {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ "#)
+ .file("src/lib.rs", "");
+ p.build();
+
+ assert_that(p.cargo("build"),
+ execs().with_status(0));
+ // Setting RUSTFLAGS forces a recompile
+ assert_that(p.cargo("build").env("RUSTFLAGS", "-Z bogus"),
+ execs().with_status(101));
+});
+
+test!(rustflags_recompile2 {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ "#)
+ .file("src/lib.rs", "");
+ p.build();
+
+ assert_that(p.cargo("build").env("RUSTFLAGS", "--cfg foo"),
+ execs().with_status(0));
+ // Setting RUSTFLAGS forces a recompile
+ assert_that(p.cargo("build").env("RUSTFLAGS", "-Z bogus"),
+ execs().with_status(101));
+});
+
+test!(rustflags_no_recompile {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ "#)
+ .file("src/lib.rs", "");
+ p.build();
+
+ assert_that(p.cargo("build").env("RUSTFLAGS", "--cfg foo"),
+ execs().with_status(0));
+ assert_that(p.cargo("build").env("RUSTFLAGS", "--cfg foo"),
+ execs().with_stdout("").with_status(0));
+});